﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Mes.Pendant.Migrations
{
    /// <inheritdoc />
    public partial class dblog2 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_Workstations",
                table: "Workstations");

            migrationBuilder.DropColumn(
                name: "WarehouseSettingsId",
                table: "Workstations");

            migrationBuilder.RenameTable(
                name: "Workstations",
                newName: "Workstation");

            migrationBuilder.RenameColumn(
                name: "WarehouseName",
                table: "Workstation",
                newName: "WorkstationPlace");

            migrationBuilder.RenameColumn(
                name: "WarehouseHead",
                table: "Workstation",
                newName: "WorkstationName");

            migrationBuilder.RenameColumn(
                name: "WarehouseCode",
                table: "Workstation",
                newName: "WorkstationCode");

            migrationBuilder.RenameColumn(
                name: "WarehouseArea",
                table: "Workstation",
                newName: "WorkshopName");

            migrationBuilder.RenameColumn(
                name: "Location",
                table: "Workstation",
                newName: "ProcessBelongs");

            migrationBuilder.RenameColumn(
                name: "IsFreeze",
                table: "Workstation",
                newName: "State");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Workstation",
                table: "Workstation",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "MaterialManagement",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    MaterialCode = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MaterialName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SpecificationsModels = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Unit = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Products = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MaterialType = table.Column<int>(type: "int", nullable: false),
                    State = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    SafetyStock = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialManagement", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MaterialType",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    MaterialTypeName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderBy = table.Column<int>(type: "int", nullable: false),
                    Products = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    State = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialType", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "UnitMeasure",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    UnitMeasureCode = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UnitMeasureName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsPrimaryUnit = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    ConversionScale = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    State = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UnitMeasure", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MaterialManagement");

            migrationBuilder.DropTable(
                name: "MaterialType");

            migrationBuilder.DropTable(
                name: "UnitMeasure");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Workstation",
                table: "Workstation");

            migrationBuilder.RenameTable(
                name: "Workstation",
                newName: "Workstations");

            migrationBuilder.RenameColumn(
                name: "WorkstationPlace",
                table: "Workstations",
                newName: "WarehouseName");

            migrationBuilder.RenameColumn(
                name: "WorkstationName",
                table: "Workstations",
                newName: "WarehouseHead");

            migrationBuilder.RenameColumn(
                name: "WorkstationCode",
                table: "Workstations",
                newName: "WarehouseCode");

            migrationBuilder.RenameColumn(
                name: "WorkshopName",
                table: "Workstations",
                newName: "WarehouseArea");

            migrationBuilder.RenameColumn(
                name: "State",
                table: "Workstations",
                newName: "IsFreeze");

            migrationBuilder.RenameColumn(
                name: "ProcessBelongs",
                table: "Workstations",
                newName: "Location");

            migrationBuilder.AddColumn<int>(
                name: "WarehouseSettingsId",
                table: "Workstations",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddPrimaryKey(
                name: "PK_Workstations",
                table: "Workstations",
                column: "Id");
        }
    }
}
